
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Alternating Iterations</title>

<style type="text/css">
/*margin and padding on body element
  can introduce errors in determining
  element position and are not recommended;
  we turn them off as a foundation for YUI
  CSS treatments. */
body {
	margin:0;
	padding:0;
}
</style>

<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" />
<script type="text/javascript" src="../../build/yui/yui-min.js"></script>


<!--begin custom header content for this example-->
<link href="assets//anim.css" rel="stylesheet" type="text/css">

<!--end custom header content for this example-->

</head>

<body class="yui3-skin-sam  yui-skin-sam">

<h1>Alternating Iterations</h1>

<div class="exampleIntro">
	<p>This demonstrates how to use the <code>iterations</code> attribute to run multiple iterations of the animation.</p>
<p>Mouse over the link to begin the animation.</p>

			
</div>

<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->

    
<a href="#" id="demo">hover me</a>
<script type="text/javascript">
YUI({filter:'raw'}).use("anim", function(Y) {
    var node = Y.one('#demo');

    var anim = new Y.Anim({
        node: node,
        from: {
            backgroundColor:node.getStyle('backgroundColor'),
            color: node.getStyle('color'),
            borderColor: node.getStyle('borderTopColor')
        },

        to: {
            color: '#fff',
            backgroundColor:'#ffa928',
            borderColor: '#71241a'
        },

        duration: 0.5,
        iterations: 'infinite',
        direction: 'alternate'
    });

    var hover = function(e) {
        var reverse = false,
            iterations = 'infinite';

        if (anim.get('running')) {
            anim.stop();
        }

        if (e.type === 'mouseout') {
            reverse = true;
            iterations = 1;
        }

        anim.setAttrs({
            'reverse': reverse,
            'iterations': iterations
        });

        anim.run();
    };

    node.on('mouseover', hover);
    node.on('mouseout', hover);
});

</script>

<!--END SOURCE CODE FOR EXAMPLE =============================== -->

</body>
</html>
